﻿@model FC.Data.ViewModels.Contests.SubmitModel

@{
    ViewBag.Title = "提交： ";//; + Model.ProbelmTitle;
    Layout = "~/Views/Shared/_ContestsContentLayout.cshtml";
}

@using (Ajax.BeginForm(
    "Submit",
    "Contests",
    new AjaxOptions()
    {
        OnSuccess = "Success",
        OnFailure = "Failure"
    }
))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(model => model.UserId)
    @Html.HiddenFor(model => model.ProblemId)
    <h2>ViewBag.Title</h2>
    <div class="row clearfix">
        <div class="form-group">
            @Html.LabelFor(model => model.SubmitText, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextAreaFor(model => model.SubmitText, new { @class = "form-control", style = "height:500px;", rows = 10 })
                @Html.ValidationMessageFor(model => model.SubmitText, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10" style="text-align:center">
                <button id="Save" type="submit" class="btn btn-success" style="margin-right:30px;">保 存</button>
                <a class="btn btn-default" href="~/Manager/Problems/@ViewBag.Collection">返 回</a>
            </div>
        </div>
    </div>
}

@section Script{
    <script>
        function Success(result) {
            if (result.state == "ok") {
                alert("保存成功");
                window.location = "/Manager/Problems/@ViewBag.Collection";
            }
            else {
                alert(result.message);
            }
        }
        function Failure() {
            alert("保存失败");
        }
    </script>
}